package pers.lance.exam.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.lance.exam.pojo.Base;
import pers.lance.exam.service.BaseService;

import java.util.List;

/**
 * @ Author     ：LILA3
 * @ Date       ：Created in 1:54 PM 7/31/2018
 */
@RestController
@RequestMapping("/base")
public class BaseController {
    @Autowired
    BaseService baseService;

    @GetMapping("/list")
    public List<Base> list() {
        return baseService.listBase();
    }

    @PostMapping("/add")
    public Base add(@RequestBody Base base) {
        return baseService.addBase(base);
    }

    @PostMapping("/delete/{id}")
    public Base delete(@PathVariable("id") String id) {
        Base base = new Base();
        base.setId(id);
        return baseService.deleteBase(base);
    }

    @GetMapping("/get")
    public Base getById(@RequestBody Base base) {
        return baseService.getBaseById(base);
    }

}
